/*
ID: icerupt1
PROG: sprime
LANG: C++11
*/
#include <fstream>
#include <iostream>
#include <vector>
#include <deque>

std::vector<int> const last{1, 3, 7, 9};
std::vector<int> const len_one{2, 3, 5, 7};
int n;

int length(int x)
{
	int l = 0;
	for (; x; x /= 10) l++;
	return l;
}

bool is_prime(int x)
{
	for (int i = 2; i*i <= x; i++) if (x%i == 0) return false;
	return true;
}

int main()
{
	std::ifstream fin {"sprime.in" };
	std::ofstream fout{"sprime.out"};

	fin >> n;
	if (n == 1) {
		for (auto v: len_one) fout << v << "\n";
		return 0;
	}

	std::deque<int> sprime(len_one.begin(), len_one.end());
	for (int i = 1; i < n; i++) {
		for (int now = sprime.front(); length(now) <= i; now = sprime.front()) {
			sprime.pop_front();
			for (auto d:last)
				if (is_prime(10*now + d)) sprime.push_back(10*now + d);
		}
	}
	for (auto s: sprime) fout << s << "\n";
}
